package cn.tedu.file;
/**
 * @Author 金帮嘉诚  @Date 2021-06-17 周四 19:55
 */
/*本类用于测试字符输入流*/

import java.io.*;

/**
 知识点：
 Reader()
 FileReader()
 BufferedReader()

 */
public class TestIn2 {
    public static void main(String[] args) {
        method1();
        method2();
    }

    private static void method2() {
        Reader in=null;

        try {
//            in=new BufferedReader(new FileReader(new File("D:\\ready\\2.txt")));
            in=new BufferedReader(new FileReader("D:\\ready\\2.txt"));

            int b;
            while ((b=in.read())!=-1){
                System.out.println(b);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method1() {
        Reader in=null;

        try {
//            in=new FileReader(new File("D:\\ready\\2.txt"));
            in=new FileReader("D:\\ready\\2.txt");

            int b;
            while ((b=in.read())!=-1){
                System.out.println(b);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
